#pragma once
#include "CGridListCtrlEx\CGridColumnTraitImage.h"
#include <afxcmn.h>

class CGridColumnTraitIP :
	public CGridColumnTraitImage
{
public:
	CGridColumnTraitIP();
	virtual ~CGridColumnTraitIP();

	virtual CWnd* OnEditBegin(CGridListCtrlEx& owner, int nRow, int nCol);
	virtual CWnd* OnEditBegin(CGridListCtrlEx& owner, int nRow, int nCol, CPoint pt) { return CGridColumnTraitImage::OnEditBegin(owner, nRow, nCol, pt); }
protected:
	virtual void Accept(CGridColumnTraitVisitor& visitor);
	virtual CIPAddressCtrl* CreateIPAddressCtrl(CGridListCtrlEx& owner, int nRow, int nCol, DWORD dwStyle, const CRect& rect);

};

class CGridEditorIPCtrl :public CIPAddressCtrl
{
public:
	CGridEditorIPCtrl(int nRow, int nCol);
	virtual void EndEdit(bool bSuccess);

protected:
	afx_msg void OnKillFocus(CWnd *pNewWnd);
	afx_msg void OnIPNChange(NMHDR *pNMHDR, LRESULT *pResult);

	virtual void PostNcDestroy();
	virtual	BOOL PreTranslateMessage(MSG* pMsg);


	int		m_Row;					//!< The index of the row being edited
	int		m_Col;					//!< The index of the column being edited
	bool	m_Completed;			//!< Ensure the editor only reacts to a single close event
	bool	m_Modified;				//!< Register if text was modified while the editor was open
	bool	m_InitialModify;		//!< Initial text modication should not set that the editor text was modified

	DECLARE_MESSAGE_MAP();
private:
	CGridEditorIPCtrl();
	CGridEditorIPCtrl(const CGridEditorIPCtrl&);
	CGridEditorIPCtrl& operator=(const CGridEditorIPCtrl&);
};